package 笔试;

import java.util.Scanner;
import java.util.Stack;

public class 数组的最大深度 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        Stack<Character> st = new Stack<>();
        int res = 0;
        int i = 0;
        while(i < str.length()) {
            if(str.charAt(i) == '[') {
                st.push(str.charAt(i));
                i++;
                res = Math.max(res, st.size());
            } else if(str.charAt(i) == ']') {
                st.pop();
                i++;
            } else {
                i++;
            }
        }
        System.out.println(res);
    }
}
